/**
 * @Author: Bobby
 * @Date: 2022-03-10 17:35:11
 * @LastEditTime: 2022-03-10 17:36:13
 * @LastEditors: Bobby
 * @Description:
 * @FilePath: \wms-v2\src\ve\utils\getModelInfo.js
 * @CIMC-V2
 */
import isEmpty from 'lodash/isEmpty'
import { getModel, recursiveList } from '@ve/utils/utils'
export function getModelInfo(vm, id) {
  let _layerList = recursiveList([vm.$store.getters['preview/getNowPageData']])
  let _modelInfo = {}
  for (let i = 0; i < _layerList.length; i++) {
    // 由于这里筛选逻辑排除了页面组件, 导致了 AtoB 动作将值丢给页面组件会报’找不到组件‘错误
    // 修改获取逻辑
    if (_layerList[i]._id === id) {
      _modelInfo = _layerList[i]
    } else {
      _modelInfo = getModel(_layerList[i]['pageModules'], id)
    }
    if (!isEmpty(_modelInfo)) {
      break
    }
  }
  return _modelInfo
}
